package com.flying.framework.annotation;

public interface ConstantEnum<T> {
	T value();
	String text();
	
	default  boolean equalsByValue(T x) {
		return value().equals(x);
	}

	@SuppressWarnings({ "rawtypes"})
	public static Object valueOf(Object t) {
		Class c = new SecurityManager() {
			public Class getMyClass() {
				return getClassContext()[1];
				}
			}.getMyClass();
			Object[] arr = c.getEnumConstants();
		for(Object o: arr) {
			ConstantEnum a = (ConstantEnum)o;
			if(a.value().equals(t)) {
				return a;
			}
		}
		return null;
	}
}
